qui(function (require, exports, module) {
    Ticket.Model = (function () {
        var divPanel = $("#liveEpisodeDiv");

        function createModelHtml() {

        }

        function getSubmitData() {

        }

        function fillModelHtml(rdata) {
            divPanel.show();
            divPanel.find("span[name=pname]").html(rdata.pname);
            divPanel.find("span[name=time_range]").html(rdata.startPlayTime + "~" + rdata.endPlayTime);
            divPanel.find("span[name=boss_status]").html(transBossStatus(rdata.bossStatus));
            divPanel.find("span[name=episodeGrade]").html(transEpisodeGrade(rdata.episodeGrade));
        }

        function transBossStatus(bossStatus) {
            var enumValue = "";
            switch (bossStatus) {
                case "FREE":
                    enumValue = "免费";
                    break;
                case "PAIED_NOT_AVAILABLE":
                    enumValue = "<span style='color: red'>付费未划价</span>";
                    break;
                case "PAIED_AVAILABLE":
                    enumValue = "<span style='color: red'>付费已划价</span>";
                    break;
                default:
                    enumValue = "Unknown " + bossStatus;
                    break;
            }
            return enumValue;
        }

        function transEpisodeGrade(episodeGrade) {
            var rest = episodeGrade % 10;
            var level = parseInt((episodeGrade -100) / 10);
            var retValue = String.fromCharCode(65+level)+"类";
            switch (rest) {
                case 1:
                    retValue +="一";
                    break;
                case 2:
                    retValue +="二";
                    break;
                case 3:
                    retValue +="三";
                    break;
            }
            retValue+="级"
            return retValue;
        }
        function transTest(test){
            return test == 0 ? "正式":"测试";
        }

        function clearModelView() {
            divPanel.hide();
        }

        function underUsing() {
            return divPanel.is(":visible")
        }

        function parseFormat(type,rdata){
            if(type == 1){
                return decodeLiveDetail(rdata );
            }
            return rdata;
        }

        function decodeLiveDetail(rdata){
            var jsonObj = JSON.parse(rdata)
            var htmlArr =[];
            htmlArr.push("频道奇谱ID:"+(jsonObj.channelQipuId||"")+","+"节目奇谱ID:"+jsonObj.qipuId);
            htmlArr.push("节目时间:"+jsonObj.startPlayTime+"~"+jsonObj.stopPlayTime);
 //           htmlArr.push(transBossStatus(jsonObj.bossStatus )+","+transEpisodeGrade(jsonObj.episodeGrade )+","+ transTest(jsonObj.test))
           return htmlArr.join("<br>")
        }
        return {
            createModelHtml: createModelHtml,
            getSubmitData: getSubmitData,
            fillModelHtml: fillModelHtml,
            clearModelView: clearModelView,
            underUsing: underUsing,
            parseFormat:parseFormat,
            decodeLiveDetail:decodeLiveDetail
        }
    })()
});